package com.zmj.project.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zmj.project.bean.Project;
import com.zmj.project.service.ProjectService;
import com.zmj.utils.Response;

@Controller
@RequestMapping("/project/")
public class ProjectController {
	@Resource
	private ProjectService projectService;

	@RequestMapping("getName")
	public String getName(HttpServletRequest request) {

		List<Project> projects = projectService.getName();
		request.setAttribute("projects", projects);
		return "project";
	}

	@RequestMapping("AddWorkOrder")
	@ResponseBody
	public Response AddWorkOrder(HttpSession session, Project project) {
		Response rs = new Response();
		if (project != null) {
			session.setAttribute("project", project);
		}
		rs.setCode(1);
		return rs;
	}

	@RequestMapping("toAddWorkOrder")
	public String toAddWorkOrder() {
		return "addworkorder";
	}
}
